<?php
class Form_User extends Zend_Form
{
    public function __construct($options=array())
    {
		parent::__construct($options);
		$this->setMethod('post');
		$this->addPrefixPath('Lion_Form_Element', '../library/Form/Element/', 'element');	
	   
	    $this->addElement('text', 'first_name', array(
            'label'      => 'First Name: *',
            'required'   => true,
            'filters'    => array('StringTrim'),
            'class'		 => 'inp-form',
            'validators' => array(
            	array('validator' => 'StringLength', 'options' => array(0, 100))
            )
        ));
		
		$this->addElement('text', 'last_name', array(
            'label'      => 'Last Name: *',
            'required'   => true,
            'filters'    => array('StringTrim'),
            'class'			 => 'inp-form',
            'validators' => array(
            	array('validator' => 'StringLength', 'options' => array(0, 100))
            )
        ));
		
		$this->addElement('text', 'email_address', array(
            'label'      => 'Email Address',
            'required'   => true,
            'filters'    => array('StringTrim'),
            'class'			 => 'inp-form',
            'validators' => array(
            	array('validator' => 'StringLength', 'options' => array(0, 100))
            )
        ));
        
        if(empty($options))
        {		
			$this->addElement('text', 'username', array(
	            'label'      => 'Username:',
	            'required'   => true,
	            'filters'    => array('StringTrim'),
	            'class'		 => 'inp-form',	            
	            'validators' => array(
	            	array('validator' => 'StringLength', 'options' => array(0, 100))
	            )
	        ));
        }    
		
        if(empty($options))
        {
        	$this->addElement('password', 'password', array(
	            'label'      => 'Password:',
	            'required'   => true,
	            'filters'    => array('StringTrim'),
	            'class'		 => 'inp-form',
	            'validators' => array(
	            	array('validator' => 'StringLength', 'options' => array(0, 100))
	            )
	        ));
        }    
        
        if(Zend_Auth::getInstance()->getStorage()->read()->userlevel == 'superadmin')
        {        
	        $userlevel = new Zend_Form_Element_Select('userlevel');
	        $userlevel ->setLabel('User Level')
			 			 ->addMultiOptions(array(
			 			    '' => 'Select User Level',            
							'admin' => 'Admin',
							'bde'   => 'Business Development Executive',
							'bse' 	=> 'Business Solution Executive',
							'bsc' 	=> 'Business System Consultant',
							'pl' 	=> 'Project Leader',
							'dev' 	=> 'Developer'));
			
			$this->addElement($userlevel);        	
						
			$status = new Zend_Form_Element_Select('status');
	        $status ->setLabel('Status')
			 			 ->addMultiOptions(array(
							'' => 'Select User Status',
			 			    1 => 'Active',
							0 => 'Pending'));
							
			$this->addElement($status);
        }	
		
		if(!empty($options))
		{
    		if($options['action'] == "edit" || $options['action'] == "editprofile")
    		{ 
        	   	$this->addElement('hidden', 'userid', array(	            
        	            'filters'  => array('int'),
        	            'class'	   => 'hidden',
        	            'value'    => $options['userid'],	            
        	    ));
    		}
		}	
		
		//$this->setDecorators( array( array('ViewScript', array('script' => 'index.phtml'))));  
    }
}
